
import 'package:flutter/material.dart';
import 'package:get/get.dart';
// import 'package:webview_flutter_platform_interface/webview_flutter_platform_interface.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';



class WebViewPage extends StatefulWidget {

  @override
  State<WebViewPage> createState() => _WebViewPageState();
}

class _WebViewPageState extends State<WebViewPage> {
final  initialUrl = Get.parameters['url']??'';
  
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      extendBodyBehindAppBar: true,
      appBar:AppBar(
        backgroundColor:Colors.transparent,
        elevation: 0, 
        title: Text('')),
      body: InAppWebView(
     
                      initialUrlRequest: URLRequest(url: WebUri(initialUrl)),
                      onWebViewCreated: (controller) async {
                      },
                      onConsoleMessage: (controller, consoleMessage) {
                        debugPrint("页面日志: ${consoleMessage.message}");
                      },
                      onLoadStart: (controller, url) {
                        setState(() {
                          // _isLoading = true;
                        });
                      },
                      onLoadStop: (controller, url) async {
                        // final canGoBack = await controller.canGoBack();
                        setState(() {});
                      },
                      onProgressChanged: (controller, progress) {},
                      onReceivedError: (controller, request, error) {
                        debugPrint('加载失败: ${error.description}');
                      },
                      initialSettings: InAppWebViewSettings(
                        supportZoom: false,
                        javaScriptEnabled: true,
                         useHybridComposition: true,
                         useWideViewPort: false,
                        preferredContentMode: UserPreferredContentMode.MOBILE,
                        disableHorizontalScroll: false,
                        disableVerticalScroll: false,
                        horizontalScrollBarEnabled: false,
                        verticalScrollBarEnabled: false,
                        mediaPlaybackRequiresUserGesture: false,
                        allowsInlineMediaPlayback: true,
                        javaScriptCanOpenWindowsAutomatically: true,
                        transparentBackground: false,
                      ),
                    ),
    );
  }
}
